
for i in {1..11}; do; curl -u rb010:cOY5VuUW3j0a -O -C - http://archive.jive.nl/exp/RB010_231116/fits/rb010_2_1.IDI$i; done

 
* wget -t45 -l1 -r -nd http://archive.jive.nl/exp/RB004_171002/pipe -A "rb004.tasav*"


wget http://archive.jive.nl/exp/RB004_171002/pipe/rb004.tasav.FITS
http://archive.jive.nl/exp/RB010_231116/pipe/rb010_1.tasav.FITS

curl -u rb010:cOY5VuUW3j0a -O -C - http://archive.jive.nl/exp/RB010_231116/pipe/rb010_1.tasav.FITS

curl -u rb010:cOY5VuUW3j0a -O -C - http://archive.jive.nl/exp/RB010_231116/pipe/rb010_2.tasav.FITS

curl -u rb010:cOY5VuUW3j0a -O -C - http://archive.jive.nl/exp/RB010_231116/pipe/rb010_3.tasav.FITS



Notes on rb010
AIPSID 010 (before recorrelation, done)
AIPSID 011 (after recorrelation, do walkthrough)

Did a preview data reduction using only a few fits files, everything looks good, need to do gypsy phase referencing. Gonna re-start using all fits files.

Doing FRING DELAY seems to mess with the maser scalar averaged flux.
This is unexpected.
Even doing ACFIT after DELAY fring dosent save you from the problem.
The first time I tried this data I did ACFIT and then FRING, then
I reversed the two. The problem with the latter is that you cant get
a decent calibrated spectrum. My plan will be to take my spectrum for
publication at the post ACFIT and preFRING stage. We'll see how the
flux density fares later.


*******
*FITLD
*******
task 'fitld'
default
indisk 1
outdisk 1
digicor -1 

clint 0.25
wtthresh 0.5

datain 'PWD:rb010_1_1.IDI
OUTNAME 'CONT'
doconcat 1 
ncount 6
*go; wait; pcat
AIPS 1:     1    10 MULTI       .UVDATA.    1 UV 22-NOV-23 20:06:23

datain 'PWD:rb010_3_1.IDI
OUTNAME 'LINE'
doconcat 1 
ncount 91
go; wait; pcat




*******
*LISTR
*******
default listr; 
indisk 1
getn 1; opty 'scan'; go; wait


docrt -1  ; getn 1; outprint 'PWD:listr.txt'; go; wait

  ID Source           Qual  Calcode RA(2000.0)     Dec(2000.0)  No. vis
   1 G23.389         : 0001         18:33:14.3248 -08:23:57.472  109769 Target 
   2 NRAO530         : 0001         17:33:02.7058 -13:04:49.548   10079 FF
   3 J1256-0547      : 0001         12:56:11.1666 -05:47:21.525       0
   4 J1743-0350      : 0001         17:43:58.8561 -03:50:04.617   13716 Delay cal
   5 J1825-0737      : 0001         18:25:37.6095 -07:37:30.013   86165 Phase Ref


'NRAO530''J1743-0350''J1825-0737''


*******
*PRTAN
*******
task 'prtan';
default ;
indisk 1; getn 1;
go;wait

 
Ant   1 = JB       BX= -1045214.5486 BY=   360269.1623 BZ=  1021477.6447
Ant   2 = WB       BX=  -466950.2635 BY=   214812.3400 BZ=  1000113.2991
Ant   3 = EF       BX=  -471719.6307 BY=     4906.7345 BZ=   835622.5966
Ant   4 = MC       BX=  -151300.3584 BY=  -511977.8385 BZ=   384751.0112
Ant   5 = O8       BX=   -98155.9800 BY=   596838.8920 BZ=  1284855.7990
Ant   6 = TR       BX=   335440.6447 BY=   217083.9972 BZ=  1012228.4566
Ant   7 = HH       BX=  1402470.4019 BY= -1528392.6403 BZ= -6833505.0706
Ant   8 = IR       BX=   495429.7345 BY=   646459.3528 BZ=  1294456.2633



docrt -1; outprint 'PWD:prtan.txt
go; wait














*********************************************** TASAV START
*******
*FITLD  Get tasav data (EVN calibration pipeline's CL and flag file)
*******
tget fitld
default
outdisk 1
datain 'PWD:rb010_1.tasav.FITS
*go; wait
datain 'PWD:rb010_2.tasav.FITS
go; wait



*******
*TACOP  Copy them into our getn
*******
default tacop
indisk 1; outdisk 1
getn 1; geto 1
*getn 4; geto 2

inext 'cl'
inver 2
ncount 1
go; wait; imh
LOCALH> TACOP1: Copied CL file from vol/cno/vers  1    2   2 to  1    1   2

inext 'fg'
inver 1
go ; wait; 
getn 1; imh
LOCALH> TACOP1: Copied FG file from vol/cno/vers  1    2   1 to  1    1   1


inext 'bp'
inver 1;
go;
LOCALH> TACOP1: Copied BP file from vol/cno/vers  1    2   1 to  1    1   1


*******
*SNPLT (Plot CL table)
*******
tget snplt
default; 
indisk 1; getn 1; inext 'CL'; inver 2; optype 'AMP'
dotv 1; nplots 8;bif 1; eif 1; xinc 0; tvinit 
Stokes 'R'
pixrange 0; go; wait



*********************************************** TASAV END

























******************************** Inspect data thoroughly

******* Jerusalem artichokes
            _   _      _           _        
           | | (_)    | |         | |       
  __ _ _ __| |_ _  ___| |__   ___ | | _____ 
 / _` | '__| __| |/ __| '_ \ / _ \| |/ / _ \
| (_| | |  | |_| | (__| | | | (_) |   <  __/
 \__,_|_|   \__|_|\___|_| |_|\___/|_|\_\___|
    
    
    



******* Set rest frequency of maser to enable Vel axis POSSM
*SETJY    
*******
default setjy
indisk 1; getn 1

**** 6.18 Methanol
restfreq 6.181E+9 146000
**** 6.7 Methanol
 restfreq 6.668E+9 519200
**** 12.2 Methanol
*restfreq 1.2178E+10, 5970000
**** 22 GHz water
*restfreq 2.223E+10, 5080000
**** 22.73 Ammonia 
*restfreq 2.273e10, 2429000
**** 23.1 Methanol
*restfreq 2.07?e10, 1024000
**** 23.1 Methanol
*restfreq 2.312e10, 1024000

veltyp 'lsr'
veldef 'radio'
optype 'VCAL'

sources 'G23.389'
go; wait


   


*******  Check if the maser is detected
*POSSM   Check the maser velocity (ch 4110 peak)
*******  Check which CONTs are bright
*******   Check if CL2 gives a decent flux
tget possm; 
default ; tvinit;
indisk 1; getn 1

doband -1; bpver 1
docal 1; gainuse 2
stokes 'half'
solint 66

bchan 0; echan 0
dotv 1; nplots 2

timerang 0

* Auto/cross/BP 1/0/2
aparm(8)=0

* scalar/vector -1/1
aparm(1)=1

* chan/freq/vel 0/1/2
aparm(7)=0


***************** LINE

source 'G23.389' 
*go; wait 

**** 6.7 GHz data
i=2047
bchan = i-100; echan=i+100
go; wait 



* Check the reliability of the antabs
docal 1; gainuse 2; aparm(8)=1; solint 0; go


 	     R  L  	
Ant   1 = JB 20 20  
Ant   2 = WB 60 50  
Ant   3 = EF 40 20  
Ant   4 = MC 100 x  
Ant   5 = O8 25 30 
Ant   6 = TR 120 100  
Ant   7 = HH 110 120  
Ant   8 = IR <10 <10 


Best refant (ampl) is Tr / Hh


**************** Check CONTS

  ID Source           Qual  Calcode RA(2000.0)     Dec(2000.0)  No. vis
   1 G23.389         : 0001         18:33:14.3248 -08:23:57.472  109769
   2 NRAO530         : 0001         17:33:02.7058 -13:04:49.548   10079
   3 J1256-0547      : 0001         12:56:11.1666 -05:47:21.525       0
   4 J1743-0350      : 0001         17:43:58.8561 -03:50:04.617   13716
   5 J1825-0737      : 0001         18:25:37.6095 -07:37:30.013   86165 pharef

'NRAO530''J1743-0350''J1825-0737''


tget possm
getn 1; aparm(9)=1; beif 1; eif 0; bchan 0; echan 0
doband -1; 
bchan 0; echan 0

aparm(2)=1; aparm(5)=-180; aparm(6)=180

*PhaRef
sources 'J1825-0737''
go; wait
* detected sometimes! 

sources 'NRAO530''
go; wait
* strong detection


sources 'J1256-0547''
go; wait
* ?

sources 'J1743-0350''
go; wait
* strong detection


    

*********************** End detection check




*******
*VPLOT   Check what timeranges we have good data
*******  make notes for flagging
default vplot; tvinit; dotv 1; 
indisk 1; 
docal 1; gainuse 2

Bif 1; eif 1
getn 1;
bchan i; echan i;
do3col 1; stokes 'half'

solint 10/60; 
nplots 9; 

go; wait 

    
*******   UV coverage
*VPLOT    
*******
default uvplt; indisk 1; tvinit
dotv 1; getn 1
BPARM=6,7,2,0
docal 1; gainuse 2
bchan i; echan i
source 'G23.389''
go; wait;



*******
*VPLOT  check time variation of the AC flux
******* 
default vplot; indisk 1; getn 1; dotv 1; nplots 7; tvinit
docal 1; gainuse 2
bparm(3)=1; bparm(6)=100; bparm(7)=1000
optype 'AUTO'; source 'G23.389' 
j = i
getn 1
grchan 1; bchan j; echan j; go; wait
grchan 2; bchan j-100; echan j-100; go; wait






*******
*VPLOT  check what the JIVE flag table does
******* 
default vplot; indisk 1; getn 1; dotv 1; nplots 7; tvinit
docal 1; gainuse 2
bparm(3)=1; bparm(6)=100; bparm(7)=3000
optype 'AUTO'; source 'G23.389' 

bchan i; echan i;

flagver -1; grchan 1;  go; wait
flagver  1; grchan 2;  go; wait

* yellow is without flags, red is with flags



************************* Notes (cumulative)


MC LL is broke
Wb and Jb not great detections even for strong sources 


************************** Thorough inspection end









*******   RadPlot
*UVPLT.   Look for wayward antennas 
*******
default uvplt; indisk 1; tvinit
stokes 'half'; do3col 1
bparm 0 1
dotv 1; getn 1

*** Fix yrange
*bparm(3)=1
*bparm(7)=900

* binning
bparm(8)=10000

source 'G23.389''

bchan i; echan i

grchan 1; docal -1; go; wait; 

grchan 2; docal 1; gainuse 2; go; wait; 
grchan 3; bchan = i-50; echan bchan; go; wait; 


************************* Notes (cumulative)
*** Notes 

Everything looks reasonable so far

************* END antenna based flux calibrations






















****** AIPS products (AUTO Super)

*******  If you're happy with the AUTOs calibration
*POSSM   make a super AUTO spectrum (vel, stokes I)
******* 
default possm; tvinit;
indisk 1; getn 1; 

bchan 0; echan 0
dotv 1;  aparm(9)=1

* Auto/cross/BP 1/0/2
aparm(8)=1

* scalar/vector -1/1
aparm(1)=-1

* chan/freq/vel 0/1/2
aparm(7)=2

doband -1; docal 1; gainuse 2

solint 0;  stokes 'I'
nplots 0;

bchan = i-100; echan=i+100


source 'G23.389''
go; wait 


OUTTEXT 'PWD:RB010_recor_G23_ACFIT_SuperAuto.txt
OUTTEXT 'PWD:RB010_GERAF.txt



Ant   1 = JB       BX= -1045214.5486 BY=   360269.1623 BZ=  1021477.6447
Ant   2 = WB       BX=  -466950.2635 BY=   214812.3400 BZ=  1000113.2991
Ant   3 = EF       BX=  -471719.6307 BY=     4906.7345 BZ=   835622.5966
Ant   4 = MC       BX=  -151300.3584 BY=  -511977.8385 BZ=   384751.0112
Ant   5 = O8       BX=   -98155.9800 BY=   596838.8920 BZ=  1284855.7990
Ant   6 = TR       BX=   335440.6447 BY=   217083.9972 BZ=  1012228.4566
Ant   7 = HH       BX=  1402470.4019 BY= -1528392.6403 BZ= -6833505.0706
Ant   8 = IR       BX=   495429.7345 BY=   646459.3528 BZ=  1294456.2633



**** Get the baseline value:
sed -e '1,/Channel/ d' RB010_GERAF.txt | sort -nk 6 | head -n 1 | awk '{print $6}'


*** Subtract the flux value from column $6

sed -e '1,/Channel/ d' RB010_GERAF.txt | awk '{$6=$6-800} {print $0 }' | gnuplot -e "set term postscript eps color solid enhanced 20 ; set out 'GERAF.eps' ; set size ratio 0.25; set ylabel 'Flux density [Jy/beam]'; set xlabel 'Velocity [km/s]'; set xrange [84:72]; plot '<cat' u 5:6 w lines lt 7 lw 10 notitle  "




**** Get the baseline value:
sed -e '1,/Channel/ d' RB010_recor_G23_ACFIT_SuperAuto.txt | sort -nk 6 | head -n 1 | awk '{print $6}'


*** Subtract the flux value from column $6

sed -e '1,/Channel/ d' RB010_recor_G23_ACFIT_SuperAuto.txt | awk '{$6=$6-44.4792} {print $0 }' | gnuplot -e "set term postscript eps color solid enhanced 20 ; set out 'Auto.eps' ; set size ratio 1; set ylabel 'Flux density [Jy/beam]'; set xlabel 'Velocity [km/s]'; set xrange [70:80] reverse; plot '<cat' u 5:6 w lines lt 7 lw 6 title '"'A-corr 6.7 GHz'"' "


**** Dont fuss too much over this because we gonna redo it later with proper amp calibration (which isnt done at this stage). 





UNICORN

      _ __,~~~/
,~~`( )_( )-\|
    |/|  `--.
    ! !  !
    











************** Rest and take notes:


********* Refant selection (based on baseline detections)
base 3
aparm(8)=0


************** Rest and take notes END
    








**************************** Take a look at antenna performance TSYS
    
   


HERE July 2023


********************************* End basic inspections






















******************************************** MANUAL PHASE CAL RRvsLL

*** pkill FRING in new Terminal to kill FRING outside of AIPS ***

  ID Source           Qual  Calcode RA(2000.0)     Dec(2000.0)  No. vis
   1 G23.389         : 0001         18:33:14.3248 -08:23:57.472  109769
   2 NRAO530         : 0001         17:33:02.7058 -13:04:49.548   10079
   3 J1256-0547      : 0001         12:56:11.1666 -05:47:21.525       0
   4 J1743-0350      : 0001         17:43:58.8561 -03:50:04.617   13716
   5 J1825-0737      : 0001         18:25:37.6095 -07:37:30.013   86165 pharef
  

calsour 'J1825-0737''NRAO530''J1256-0547''J1743-0350''


****** Find a scan which is good for manual phase cal
J1743-0350   0/11:32:21 -   0/11:36:20   






*******
*VPLOT   See how the RvsL phase diff varies vs time, 
*******.   pick a timerang and source for manual phase cal
default vplot; indisk 1; getn 1

baseline 3

solint 0.5
bparm 0, -1, 1, 0, 0, 0, 2
bparm 0, 2, 1, 0, 0, -180, 180
dotv 1; tvinit; nplots 8
stokes 'half'; do3col 1


sour 'J1825-0737''NRAO530''J1256-0547''J1743-0350''
bchan i-500; echan i+500

docal 1; gainuse 2; go; wait;






Kill and remake the NX table (because FRING was splitting the solutions into two scans (probably because the scan was split over two fits files))

default indxr; indisk 1; getn 1
cparm 666 666 0.1

go; wait




*******   Manual phase cal
*FRING    
*******  
default fring;
indisk 1; getn 1
docal 1; gainuse 2
doband -1; 
flagver 0

refant 3
aparm(9)=1
bchan 0; echan 0
aparm 2,-1
dparm 1, 0

* Delay window (nsec)
dparm(2) = 200
* Rate window (mHz)
dparm(3) = 300
* Integration time (sec)
dparm(4)=1




* J1743-0350   0/11:32:21 -   0/11:36:20   

****************.     Manual pHaCal.     *****************
******* Manual phase cal scan
 timerang 00 11 32 21 00 11 36 20
 calsour 'J1743-0350''
 solint 10
* Zero the rate, keep phase and delay
dparm(8)=1

go; wait; imh
*Creating SN 1


SN 1 solint 10, TimeRang OneScan
LOCALH> FRING1: Found       15 good solutions





*******
*SNPLT   Check FRING results for all CONT sources
*******    
default snplt
indisk 1; getn 1
tvinit; dotv 1; nplots 9

stokes 'half'; do3col 2; opcode 'ALST'
inext 'SN'; invers 1


optype 'RATE'; go; wait

optype 'DELA'; go; wait

pixrang -180, 180
optype 'phas'; go; wait; pixrang 0



***************** Manual phase cal and then rerun FRINGs

*******
*CLCAL  
*******
default clcal; 
indisk 1; getn 1; refant 3
OPCODE ='calp'
interpol 'ambg'
dobtween 1


calsour 'J1743-0350' 
SOURCES = '''

******** Manual Phase Cal

snver 1; gainver 2; gainuse 3
antennas  0
go; wait; imh 
*** Creating CL3 (ManualPhaseCal)





*******
*VPLOT   See how the RvsL phase diff varies vs time, after FRING/ManPhaCal
*******  
default vplot; indisk 1; getn 1

baseline 3

solint 0.5
bparm 0, -1, 1, 0, 0, 0, 2
bparm 0, 2, 1, 0, 0, -180, 180
dotv 1; tvinit; nplots 8
stokes 'half'; do3col 1

j=i
sour 'J1825-0737''NRAO530''J1256-0547''J1743-0350''
bchan j-100; echan j+100

**** before FRING
docal 1; gainuse 2; go; wait;

**** after ManPhCal FRING
docal 1; gainuse 3; go; wait;


sources 'J1825-0737''G23.389''
bchan j; echan j
go; wait






****** Manual phase cal worked (20:00 Feb 14)






*******    Delay 
*FRING    
*******  
default fring;
indisk 1; getn 1
docal 1; gainuse 3
doband -1; 
flagver 0

refant 3
aparm(9)=1
bchan 0; echan 0
aparm 2,-1
dparm 1, 0

* Delay window (nsec)
dparm(2) = 200
* Rate window (mHz)
dparm(3) = 300
* Integration time (sec)
dparm(4)=1


****************.     DELAY.     *****************
*********** Bright CONTs only, 10min solint
* To get a single-scan delay solution to apply to the maser data
solint 10; 

* Zero the rates and phase 
dparm(8)=5
* SNR cutoff
aparm(7)=7

* Delay window (nsec)
dparm(2) = 300
* Rate window (mHz)
dparm(3) = 100

****** Average LL and RR
aparm(3)=1

calsour 'NRAO530''J1256-0547''J1743-0350''

go; wait; imh
*Creating SN 2





*******
*SNPLT   Should be zero rate and phase, slowly changing delay
*******    
default snplt
indisk 1; getn 1
tvinit; dotv 1; nplots 9

stokes 'half'; do3col 2; opcode 'ALST'
inext 'SN'; invers 2


optype 'RATE'; go; wait

optype 'DELA'; go; wait

pixrang -180, 180
optype 'phas'; go; wait; pixrang 0



******** Delay only

*******
*CLCAL  
*******
default clcal; 
indisk 1; getn 1; refant 3
OPCODE ='calp'
interpol 'ambg'
dobtween 1


calsour 'NRAO530''J1256-0547''J1743-0350''
SOURCES = '''

snver 2; gainver 3; gainuse 4
antennas  0
go; wait; imh 
*** Creating CL4 (solint10)





*******
*SNPLT   Check FRING results for all CONT sources
*******    
default snplt
indisk 1; getn 1; 
tvinit; dotv 1; nplots 9

stokes 'half'; do3col 2; opcode 'ALST'
inext 'CL'; invers 4

optype 'DELA'; go; wait
optype 'phas'; go; wait
optype 'RATE'; go; wait


*******
*VPLOT   See how the RvsL phase diff varies vs time, after FRING/ManPhaCal
*******  
default vplot; indisk 1; getn 1

baseline 3

solint 1
bparm 0, -1, 1, 0, 0, 0, 2
bparm 0, 2, 1, 0, 0, -180, 180
dotv 1; tvinit; nplots 8
stokes 'half'; do3col 1


sources 'J1825-0737''NRAO530''J1256-0547''J1743-0350''
bchan j-150; echan j+150

**** before FRING (LL and RR should be out of phase (not overlaid))
docal 1; gainuse 2; go; wait;
 
**** after ManPhCal FRING (LL and RR should be in phase (overlaid))
docal 1; gainuse 3; go; wait;

**** after DELAY FRING 
docal 1; gainuse 4; go; wait;






*******    Mount Olympus
*POSSM    Check for phase slopes indicating delay residual
*******
default possm; tvinit;
indisk 1; getn 1; docal 1; gainuse 4
aparm 1, 1, 0,0, -180,180, 0, 0, 1
doband -1
stokes 'half'

solint 1; aparm (9)=1; nplots 4

bchan 1; echan 0
dotv 1

sources 'J1825-0737''
*go; wait


sources 'NRAO530''
go; wait


sources 'J1256-0547''
go; wait
* ?

sources 'J1743-0350''
go; wait


j= 512
bchan j-50; echan j+50
sources 'G23.389''
go; wait 

*** NOTE: Antenna 7 has shitty phase bandpass (PieT)



******************************************** END DELA FRING












End of part1




*******   FIT out MOMNTS
*FITTP
*******
default fittp; indisk 1; getn 1
dataout 'PWD:Part1.fits
go; wait









************************ Normal phaseRef attempt



*******   Full + Delay + Manual phase cal
*FRING    
*******  
default fring;
indisk 1; getn 1; 
docal 1; gainuse 4
doband -1; 
flagver 0

refant 3
aparm(9)=1
bchan 0; echan 0
aparm 2,-1
dparm 1, 0

* Delay window (nsec)
dparm(2) = 200
* Rate window (mHz)
dparm(3) = 300
* Integration time (sec)
dparm(4)=1

****** Average LL and RR
aparm(3)=1

****************.     FULL.     *****************
*********** Solint 1 just to check how detectable all sources are
calsour '-G23.389'' 

* Disable any zeroing
dparm(8)=0
* SNR cutoff
aparm(7)=5

solint 1; solsub 0; 
go; wait; imh
*Creating SN 3




*******
*SNPLT   Check FRING results for all CONT sources
*******    
default snplt
indisk 1; getn 1
tvinit; dotv 1; nplots 9

stokes 'half'; do3col 2; opcode 'ALST'
inext 'SN'; invers 3


optype 'RATE'; go; wait

optype 'DELA'; go; wait

pixrang -180, 180
optype 'phas'; go; wait; pixrang 0


* Here Nov 27 ReMake 


******** Seems like everyone except Hart made it through 

*******
*CLCAL  
*******
default clcal; 
indisk 1; getn 1; refant 3
OPCODE ='calp'
interpol 'SIMP'
dobtween 1

************* antennas
calsour ' ''
SOURCES = ' ''

snver 3; gainver 4; gainuse 5
antennas  1,2,3,4,5,6,8
go; wait; imh 

*** Creating CL5 (NormalPhaRef)




*******
*SNPLT   Check FRING results for all CONT sources
*******    
default snplt
indisk 1; getn 1; 
tvinit; dotv 1; nplots 9

stokes 'half'; do3col 2; opcode 'ALST'
inext 'CL'; invers 5

optype 'DELA'; go; wait
optype 'phas'; go; wait
optype 'RATE'; go; wait





*******
*VPLOT   See how coheerent the maser data becomes
*******  
default vplot; indisk 1; getn 1

baseline 3

solint 10/60
bparm 0, -1, 1, 0, 0, 0, 2
bparm 0, 2, 1, 0, 0, -180, 180
dotv 1; tvinit; nplots 8
stokes 'half'; do3col 1


sources 'J1825-0737''NRAO530''J1256-0547''J1743-0350''
bchan j-150; echan j+150

**** before FRING
docal 1; gainuse 2; go; wait;

**** after ManPhCal FRING
docal 1; gainuse 3; go; wait;

**** after DELAY FRING
docal 1; gainuse 4; go; wait;

**** after NormalPhaseRef FRING
docal 1; gainuse 5; go; wait;


sources 'G23.389''
bchan j; echan j
docal 1; gainuse 5; go; wait;





*******    Mount Olympus
*POSSM    Check for phase slopes indicating delay residual
*******
default possm; tvinit;
indisk 1; getn 1; docal 1; gainuse 5
aparm 1, 1, 0,0, -180,180, 0, 0, 1
doband -1
stokes 'half'

solint 1; aparm (9)=1; nplots 4

bchan 1; echan 0
dotv 1

sources 'J1825-0737''
go; wait


sources 'NRAO530''
go; wait


sources 'J1256-0547''
go; wait
* ?

sources 'J1743-0350''
go; wait


j= 2047
bchan j-50; echan j+50
sources 'G23.389''
go; wait 

                     __       __
                     '.'--.--'.-'
       .,_------.___,   \' r'
       ', '-._a      '-' .'
        '.    '-'Y \._  /
          '--;____'--.'-,
      whale /..'       '''










******************* Phase calibration (FRING and SC)

* set the RefM chan:
j = i



******* Find the rough maser astrometric coordinates
*IMAGR    Dont set the Flux parameter 
*******     
default imagr
indisk 1; outdisk 1; getn 1
nchav 0; minpatch 128; onebeam -1; maxpixel 0

cellsize 0.001 0.001
imsize 1024*2 1024*2

niter 100;

****** Flag crap data and pick nice UVRANGE
flagver 0
UVWTFN 'NA'
*UVRANGE 000 30000

source 'G23.389'

stokes 'I' 

doband -1

* (Select stations)
docal 1; gainuse 5
antennas  1,2,3,4,5,6,8
baseline  antennas

dotv -1

outname 'FindMas

bchan j-20; echan j+20
go; wait; pcat


********** TVMOVIE
default tvmovie; tvinit; indisk 1; txinc 3; tyinc 3; getn 3
tvmovie

********** TVLOD
default tvlod; tvinit; indisk 1; getn 3; 
txinc 2; tyinc 2; ltype 4; tvlod; tvlab
pixrange -0.1 3
detime 0.4
for i = 0 to 41; tblc 0 0 i;ttrc 0 0 i;tvlod; delay; end




j = 2064
i = 2047

*******
*VPLOT   See how coheerent the maser data becomes
*******  
default vplot; indisk 1; getn 1

baseline 0

solint 0.5
bparm 0, -1, 0, 0, 0, 0,100, -180,180
dotv 1; tvinit; nplots 8
stokes 'half'; do3col 1


sources 'G23.389''
bchan j; echan j
docal 1; gainuse 5; go; wait;

sources 'G23.389''
bchan i; echan i
docal 1; gainuse 5; go; wait;


** Mostly good for pretty miuch everyone 




*******   RadPlot
*UVPLT   Look for wayward antennas 
*******
default uvplt; indisk 1; tvinit
stokes 'half'; do3col 1
bparm 0 1
dotv 1; getn 1

*** Fix yrange
*bparm(3)=1
*bparm(7)=900

* binning
bparm(8)=10000

source 'G23.389''

bchan j; echan j

grchan 1; docal -1; go; wait; 

grchan 2; docal 1; gainuse 5; go; wait; 





default tvall; indisk 1; getn 3; txinc 1; tyinc 1
for i =20 to 20; tblc 0 0 i;ttrc 0 0 i;
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat


>print 9.1107E+00 / 3.970E-01
AIPS 1:     22.948864



default tvall; indisk 1; getn 3; txinc 1; tyinc 1
for i =37 to 37; tblc 0 0 i;ttrc 0 0 i;
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat





* Certainly acceptable



*******    Mount Olympus
*POSSM    Check for phase slopes indicating delay residual
*******
default possm; tvinit;
indisk 1; getn 1; docal 1; gainuse 5
aparm -1, 1, 0,0, -180,180, 0, 0, 1
doband -1
stokes 'half'

solint 1; aparm (9)=1; nplots 4

bchan 1; echan 0
dotv 1

j= 2047
bchan j-20; echan j+20
sources 'G23.389''
go; wait 








******* Find the maser astrometric coordinates using PhaseRefOK stations
*IMAGR    Dont set the Flux parameter 
*******     
default imagr
indisk 1; outdisk 1; getn 1
nchav 0; minpatch 128; onebeam -1; maxpixel 0

cellsize 0.001 0.001
imsize 1024*1 1024*1

niter 100;

****** Flag crap data and pick nice UVRANGE
flagver 0
UVWTFN 'NA'
*UVRANGE 000 30000

source 'G23.389'

stokes 'I' 

doband -1

* (Select stations)
docal 1; gainuse 5
antennas  1,2,3,4,5,6,8
baseline  antennas

dotv -1


stokes 'I' ; outname 'RefM
bchan j; echan j
go; wait; pcat





*** check the cc table of the ICL model
default prtcc; getn 5; go prtcc




*******  of the maser #1
*FRING   Separate L and R just incase, then combine them later
*******
default fring
indisk 1; getn 1

*** Input model ICL to force position
in2disk 1; get2n 5
inver 1; nmaps 1; ncomp 14
 doband -1; 

aparm(1)=2
aparm(3)=-1
aparm(7)=3
aparm(9)=1

dparm 2 0 100 0 2

refant 3

calsour 'G23.389'''
bchan j; echan j

solint 1;
docal 1; gainuse 5
 go; wait



* SN 4
** use getn 5 model (all x cc), trying to bring Hart in line





*******
*SNPLT   Check FRING results for all CONT sources
*******    
default snplt
indisk 1; getn 1
tvinit; dotv 1; nplots 9

stokes 'half'; do3col 2; opcode 'ALST'
inext 'SN'; invers 4

optype 'DELA'; go; wait
optype 'phas'; go; wait
optype 'RATE'; go; wait




******* 
*CLCAL  Apply phase SC
*******
default clcal; 
indisk 1; getn 1; refant 3
interpol 'ambg';
SOURCES = 'G23.389''
CALSOUR = 'G23.389''

snver 4; gainver 5; gainuse 6
go; wait; imh 



*******
*SNPLT   Check FRING results for all CONT sources
*******    
default snplt
indisk 1; getn 1
tvinit; dotv 1; nplots 9

stokes 'half'; do3col 2; opcode 'ALST'
inext 'CL'; invers 6

optype 'DELA'; go; wait
optype 'phas'; go; wait
optype 'RATE'; go; wait



*******
*VPLOT   See how the coheerence changes  
*******
default vplot; indisk 1; getn 1

baseline 5

solint 0.5
bparm 0, 2, 1, 0, 0, -180, 180
dotv 1; tvinit; nplots 9

SOURCES = 'G23.389'
bchan j; echan j

stokes 'half'

*yellow
grchan 1; docal 1; gainuse 5; go; wait   
*green
grchan 2; docal 1; gainuse 6; go; wait 



*** 








*******
*IMAGR   
*******
default imagr
indisk 1; outdisk 1; getn 1
nchav 0; minpatch 128; onebeam -1; maxpixel 0

cellsize 0.001 0.001
imsize 1024 1024

dotv -1; niter 500; robust 0

****** Flag crap data and pick nice UVRANGE
flagver 0
UVWTFN 'NA'
*UVRANGE 000 30000

source 'G23.389'
bchan j; echan j



doband -1
docal 1; gainuse 6
stokes 'I' ; outname 'SC_ph1
go; wait; pcat



*CL5 (QSO_FRING phaserefd good stations)
AIPS 1:     4    11 RefM        .IBM001.    1 MA 30-JUL-24 17:57:23
AIPS 1:     5    11 RefM        .ICL001.    1 MA 30-JUL-24 17:59:27

*CL6 (FRINGd maser)
AIPS 1:     6    11 SC_ph1      .IBM001.    1 MA 30-JUL-24 18:05:20
AIPS 1:     7    11 SC_ph1      .ICL001.    1 MA 30-JUL-24 18:05:20



default tvall; indisk 1; getn 5; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 1.1230E+01 / 4.448E-01
AIPS 1:     25.2473011

default tvall; indisk 1; getn 7; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 1.7888E+01 / 6.499E-02
AIPS 1:    275.2423706


















*** check the cc table of the ICL model
default prtcc; getn 7; go prtcc


*******  of the maser #2
*FRING   This time Stokes I
*******
default fring
indisk 1; getn 1

*** Input model to force position
in2disk 1; get2n 7
inver 1; ncomp 12
* NMAPS
 doband -1; 

aparm(1)=2
aparm(3)=1
aparm(7)=3
aparm(9)=1

dparm 2 0 100 0 2

refant 3

calsour 'G23.389'''
bchan j; echan j

solint 0.5;
docal 1; gainuse 5
 go; wait

* SN5
** use getn 10 model (14 x cc)
LOCALH> FRING1: Found     6264 good solutions
LOCALH> FRING1: Failed on       16 solutions







*******
*SNPLT   Check FRING results for all CONT sources
*******    
default snplt
indisk 1; getn 1
tvinit; dotv 1; nplots 9

stokes 'half'; do3col 2; opcode 'ALST'
inext 'SN'; invers 5

optype 'DELA'; go; wait
optype 'phas'; go; wait
optype 'RATE'; go; wait




******* 
*CLCAL  Apply phase SC
*******
default clcal; 
indisk 1; getn 1; refant 3
interpol 'ambg';
SOURCES = 'G23.389''
CALSOUR = 'G23.389''

snver 5; gainver 5; gainuse 7
go; wait; imh 




*******
*VPLOT   See how the coheerence changes  
*******
default vplot; indisk 1; getn 1

baseline 3

solint 0.5
bparm 0, 2, 1, 0, 0, -180, 180
dotv 1; tvinit; nplots 9

SOURCES = 'G23.389'
bchan j; echan j

grchan 2; docal 1; gainuse 6; go; wait 
grchan 3; docal 1; gainuse 7; go; wait 








*******
*IMAGR    Image and evaluate the maser using the latest CL table
*******
default imagr
indisk 1; outdisk 1; getn 1
nchav 0; minpatch 128; onebeam -1; maxpixel 0

cellsize 0.001 0.001
imsize 1024 1024

dotv -1; niter 500; robust 0

****** Flag crap data and pick nice UVRANGE
flagver 0
UVWTFN 'NA'
*UVRANGE 000 30000

source 'G23.389'
bchan j; echan j

doband -1
docal 1; gainuse 7
stokes 'I' ; outname 'SC_ph2
go; wait; pcat



*CL5 (QSO_FRING phaserefd good stations)
AIPS 1:     4    11 RefM        .IBM001.    1 MA 30-JUL-24 17:57:23
AIPS 1:     5    11 RefM        .ICL001.    1 MA 30-JUL-24 17:59:27

*CL6 (FRINGd maser)
AIPS 1:     6    11 SC_ph1      .IBM001.    1 MA 30-JUL-24 18:05:20
AIPS 1:     7    11 SC_ph1      .ICL001.    1 MA 30-JUL-24 18:05:20

*CL7 (FRINGd maser, Stokes I, solint 0.5, more nComps to include structure)
AIPS 1:     8    11 SC_ph2      .IBM001.    1 MA 30-JUL-24 18:18:32
AIPS 1:     9    11 SC_ph2      .ICL001.    1 MA 30-JUL-24 18:19:04


default tvall; indisk 1; getn 5; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 1.1230E+01 / 4.448E-01
AIPS 1:     25.2473011

default tvall; indisk 1; getn 7; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 1.7888E+01 / 6.499E-02
AIPS 1:    275.2423706

default tvall; indisk 1; getn 9; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print  1.8409E+01 / 5.026E-02 
AIPS 1:    366.2753906


****************** End phase SC












************************ Jellyfish


















************************************ Basic FLAGGING START

*** Note, do all spectral line flagging after SPLAT
 


***************************** BPASS start



*******  
*POSSM   
******* 
default possm; tvinit;
indisk 1; getn 1; 

dotv 1;  aparm(9)=1

* Auto/cross/BP 1/0/2
aparm(8)=1

* scalar/vector -1/1
aparm(1)=-1

* chan/freq/vel 0/1/2
aparm(7)=0

doband -1; docal 1; gainuse 7

solint 0;  stokes 'half'
nplots 2;


*****6.7 GHz Meth Strong detection

bchan = i-70; echan=i+70


source 'G23.389' 
go; wait 


bchan = i-270; echan=i+270


***** Tr is about 110 Jy, so we use it for spectrum template 

*******   
*BPASS
*******
default bpass; indisk 1; getn 1
calsour  'NRAO530''J1743-0350''
bpassprm(1) 1
bpassprm(9) 1
bpassprm(10) 1
solint 60
go; wait


default possm; aparm(1)=-1; aparm(8)=2; bpver 1; getn 1
bchan 0; echan 0; solint 60; dotv 1; go



******* 
*POSSM  check the BP table makes things better or not
******* 
default possm; tvinit;
indisk 1; getn 1; 
dotv 1; aparm(9)=1

* Auto/cross/BP 1/0/2
aparm(8)=1

* scalar/vector -1/1
aparm(1)=-1

* chan/freq/vel 0/1/2
aparm(7)=0

doband 1; docal 1; gainuse 2

solint 0;  stokes 'half'
nplots 4

bchan = i-60; echan=i+60


source 'G23.389''
go; wait 






***** QUACK: first, determine how many seconds to quack and which stations

*******
*VPLOT   Check what timeranges we have good data
*******  make notes for flagging
default vplot; indisk 1; getn 1; dotv 1; nplots 9; tvinit
docal 1; gainuse 2
optype 'AUTO'; source 'G23.389' 
stokes 'half'; do3col 1
getn 1
bchan j; echan j; go; wait


**** MC one pol is trash, flag it with UVFLG
**** Eff some times near 13:00 are trash, flag it with IBLED


*** No need for quack

*******FG1 -> FG2
default tacop; indisk 1; outdisk 1; getn 1; geton 2; inext 'fg'; 
invers 1; outvers 2; go
LOCALH> TACOP1: Copied FG file from vol/cno/vers  1    2   1 to  1    2   2







*******
* QUACK
*******
default quack; indisk 1; getn 1; 
flagver 3; 
SOURCES 'G23.389''

opcode 'BEG'

aparm(2)=5/60
antenna 0
*go; wait

aparm(2)=7/60
antenna 4,5
*go; wait



*******FG2 -> FG3
default tacop; indisk 1; outdisk 1; getn 1; geton 1; inext 'fg'; 
invers 3; outvers 4; go
LOCALH> TACOP1: Copied FG file from vol/cno/vers  1    1   3 to  1    1   4


******  PT is only an asshole sometimes
*UVFLG 
******  
default uvflg
indisk 1; getn 1
opcode 'flag'
outfgver 2
stokes 'LL'

antenna 4;
timer 0

 go; wait





******.   Flag bad times (leftover offsources etc)
*IBLED  Integrate the in freq (when relevant) and then flag it in time
******
default ibled; indisk 1; getn 1
docalib 1; gainuse 2
flagver 2; outfgver 2
dparm(2)=1
source 'G23.389''
bchan i; echan i
stokes 'half'
go; wait 


************************* Flagging done










**************** ACFIT


******************** Make a LINE data set (spectral zoom on the maser profile)
   





*******  
*POSSM   
******* 
default possm; tvinit;
indisk 1; getn 1; 

dotv 1;  aparm(9)=1

* Auto/cross/BP 1/0/2
aparm(8)=1

* scalar/vector -1/1
aparm(1)=-1

* chan/freq/vel 0/1/2
aparm(7)=0

doband -1; docal 1; gainuse 2

solint 0;  stokes 'half'
nplots 2;


*****6.7 GHz Meth Strong detection

bchan = i-70; echan=i+70


source 'G23.389' 
go; wait 


*** What we expect from Ibaraki = 110
*** Tr 115 RCP 115 LCP


*******
*SNPLT   Check TY tables
*******    
default snplt
indisk 1; getn 1
tvinit; dotv 1; nplots 9

do3col 2; opcode 'ALST'

inext 'TY'; invers 1

optype 'TSYS'
go; wait



*******  Look for a station whose L and R are well matched to eachother 
* VPLOT   
*******
default vplot; indisk 1; getn 1; dotv 1; nplots 9; tvinit
optype 'AUTO'; source 'G23.389' 

antenna 6
* Check the quality of the ACFIT result
stokes 'half'; docal 1; gainuse 7
bparm 0 1 1 0 0 200 650
bchan j; echan j; go; wait
grchan 2; bchan j-150; echan j-150; go; wait



*** Tr (Refant 6) seems best for ampcal




*******   
*SPLaT.      Make a zoomed LINE data set to image cube later
*******
default splat
indisk 1; outdisk 1; getn 1

docal 1; gainuse 7
doband 1
flagver 0
aparm(5)=1

sources= 'G23.389''

******* Make a spectrum template
antenna 6
solint 666
stokes 'half'
*bchan = i-150; echan=i+150
bpver 1
outclass 'ACFIT';
go; wait; recat; pcat



Kill and remake the NX table

default indxr; indisk 1; getn 10
cparm 666 666 0.1

go; wait


*******  Check it
*POSSM   
*******  
tget possm; getn 10; doband -1; docal -1;
bchan = i-150; echan=i+150
go






* Some aips distros have antennas as a paramerter, some dont, if not then get creative


Carrot
  \/_
 _/        
(,;)
(,.)
(,/
|/

********** ACFIT ***********
* ACFIT needs to be told the baseline noise region and the maser profile region


Spectrum:
            /\
            | \ /\
 ___________/  V  \__________
 <baseline><maserz><baseline>

These will be used in bparm 
 1900-1975  1975-2130  2130-2190


******** Note, BP is important because we are comparing 
* ACFIT   signal to the noise floor (whihc needs to be flat) 
******** 
task 'acfit'
default
getn 1; get2n 10
calsour 'G23.389''

docalib 1; gainuse 7
doband 1; bpver 1
solint 30


***** This is the total range of noise-signal-noise
bchan 1900
echan 2190
aparm 1 1 1 1 0 0 0 1 0 0
*if this sucks, try aparm(9)=0

* pairs of baseline channels in the source spectra
* 1 to 2 is pre-spectrum noise area, 3 to 4 is post-spectrum noise area
bparm  1900 1975 2130 2190
cparm bparm

go; wait

**** creates SN6





*******
*SNPLT   Look at SN6
*******    
default snplt; indisk 1; getn 1; tvinit; dotv 1;
stokes 'half'; do3col 2; opcode 'ALST'; nplots 9
optype 'AMP'; inext 'SN'; invers 0
go; wait

default snedt; indisk 1; getn 1; inext 'sn'; inver 6; dodelay 1; go; wait
***** SN6 -> SN7



*******
*SNPLT   Look at SN
*******    
default snplt; indisk 1; getn 1; tvinit; dotv 1;
stokes 'half'; do3col 1; opcode 'ALST'
nplots 9
inext 'SN'; invers 7; optype 'AMP'
go; wait





***		Try two CLCALs to see whats stuff
********
***************
**** CLCAL Settings such that non G358 scans pass without being touched.
** note that 'good stations' (Mc, Hh) barely change between CL2/3


**** CLCAL which int-/extrapolates solutions from G358 to all sources
default 'clcal'; indisk 1; getn 1
gainver 7; snver 7; gainuse 8
CALCODE = ''
OPCODE ='calp'
SOUCODE =''
SMOTYPE = 'full'
SAMPTYPE '2pth'
dobtween 1
calsour 'G23.389''
sources ' ''
 go; wait;

* I quite this one actually

***************
********
***



*******
*SNPLT   Look at CL8
*******    
default snplt; indisk 1; getn 1; tvinit; dotv 1;
stokes 'half'; do3col 2; opcode 'ALST'
nplots 9
inext 'CL'; invers 8; optype 'AMP'
go; wait





*******  
*POSSM   
******* 
default possm; tvinit;
indisk 1; getn 1; 

dotv 1;  aparm(9)=1

* Auto/cross/BP 1/0/2
aparm(8)=1

* scalar/vector -1/1
aparm(1)=-1

* chan/freq/vel 0/1/2
aparm(7)=0

doband 1; docal 1; gainuse 8

solint 0;  stokes 'half'
nplots 2;


*****6.7 GHz Meth Strong detection
bchan = j-150; echan=j+150


source 'G23.389' 
go; wait 


*** What we expect from Ibaraki = 110
*** Hart is probably the best eh




*******  check time variation of the AC flux
* VPLOT   
*******
default vplot; indisk 1; dotv 1; nplots 9; tvinit; getn 1;
bparm(3)=1; bparm(6)=1; bparm(7)=1000
doband -1; 
optype 'AUTO'; source 'G23.389' 

* Check the quality of the ACFIT result
docal 1; gainuse 8
grchan 1; bchan j; echan j; go; wait
grchan 2; bchan j-151; echan j-151; go; wait




************* END antenna based flux calibrations






















****** AIPS products (AUTO Super)

*******  If you're happy with the AUTOs calibration
*POSSM   make a super AUTO spectrum (vel, stokes I)
******* 
default possm; tvinit;
indisk 1; getn 1

bchan 0; echan 0
dotv 1;  aparm(9)=1

* Auto/cross/BP 1/0/2
aparm(8)=1

* scalar/vector -1/1
aparm(1)=-1

* chan/freq/vel 0/1/2
aparm(7)=2

doband 1; docal 1; gainuse 8

solint 0;  stokes 'I'
nplots 0;

bchan = j-150; echan=j+150


source 'G23.389''



OUTTEXT 'PWD:RB010_G23.389_ACFIT_SuperAuto_2.txt
go; wait 


**** Get the baseline value:
sed -e '1,/Channel/ d' RB010_G23.389_ACFIT_SuperAuto_2.txt | sort -nk 6 | head -n 1 | awk '{print $6}'

>156.923

*** Subtract the flux value from column $6

sed -e '1,/Channel/ d' RB010_G23.389_ACFIT_SuperAuto_2.txt | awk '{$6=$6-156.923} {print $0 }' | gnuplot -e "set term postscript eps color solid enhanced 20 ; set out 'Auto_ACFIT_2.eps' ; set size ratio 1; set ylabel 'Flux density [Jy/beam]'; set xlabel 'Velocity [km/s]'; set xrange [70:80] reverse; set yrange [-4:120]; plot '<cat' u 5:6 w lines lt 7 lw 6 title '"'A-corr 6.7 GHz'"' "





****** AIPS products (Cross Super)

*******  If you're happy with the AUTOs calibration
*POSSM   make a super AUTO spectrum (vel, stokes I)
******* 
default possm; tvinit;
indisk 1; getn 1

bchan 0; echan 0
dotv 1;  aparm(9)=1

* Auto/cross/BP 1/0/2
aparm(8)=0

* scalar/vector -1/1
aparm(1)=-1

* chan/freq/vel 0/1/2
aparm(7)=2

doband 1; docal 1; gainuse 8

solint 0;  stokes 'I'
nplots 0;


bchan = j-150; echan=j+150


source 'G23.389''


OUTTEXT 'PWD:RB010_G23.389_ACFIT_SuperCross.txt
go; wait 


**** Get the baseline value:
sed -e '1,/Channel/ d' RB010_G23.389_ACFIT_SuperCross.txt | sort -nk 6 | head -n 1 | awk '{print $6}'

>6.60187

*** Subtract the flux value from column $6

sed -e '1,/Channel/ d' RB010_G23.389_ACFIT_SuperCross.txt | awk '{$6=$6-6.60187} {print $0 }' | gnuplot -e "set term postscript eps color solid enhanced 20 ; set out 'Cross_ACFIT_2.eps' ; set size ratio 1; set ylabel 'Flux density [Jy/beam]'; set xlabel 'Velocity [km/s]'; set xrange [70:80] reverse; set yrange [-1:55]; plot '<cat' u 5:6 w lines lt 7 lw 6 title '"'X-corr 6.7 GHz'"' "





UNICORN

      _ __,~~~/
,~~`( )_( )-\|
    |/|  `--.
    ! !  !
    
    





*******
*IMAGR    Image and evaluate the maser using the latest CL table
*******
default imagr
indisk 1; outdisk 1; getn 1
nchav 0; minpatch 128; onebeam -1; maxpixel 0

cellsize 0.001 0.001
imsize 1024 1024

dotv -1; niter 500; robust 0

****** Flag crap data and pick nice UVRANGE
flagver 0
UVWTFN 'NA'
*UVRANGE 000 30000

source 'G23.389'
bchan j; echan j

doband 1
docal 1; gainuse 8
stokes 'I' ; outname 'SCphA0
go; wait; pcat



*CL5 (QSO_FRING phaserefd good stations)
AIPS 1:     4    11 RefM        .IBM001.    1 MA 30-JUL-24 17:57:23
AIPS 1:     5    11 RefM        .ICL001.    1 MA 30-JUL-24 17:59:27

*CL6 (FRINGd maser)
AIPS 1:     6    11 SC_ph1      .IBM001.    1 MA 30-JUL-24 18:05:20
AIPS 1:     7    11 SC_ph1      .ICL001.    1 MA 30-JUL-24 18:05:20

*CL7 (FRINGd maser, Stokes I, solint 0.5, more nComps to include structure)
AIPS 1:     8    11 SC_ph2      .IBM001.    1 MA 30-JUL-24 18:18:32
AIPS 1:     9    11 SC_ph2      .ICL001.    1 MA 30-JUL-24 18:19:04

*CL8 (Same as above but with ACFIT)
AIPS 1:    11    11 SCphA0      .IBM001.    1 MA 31-JUL-24 11:23:00
AIPS 1:    12    11 SCphA0      .ICL001.    1 MA 31-JUL-24 11:23:00








default tvall; indisk 1; getn 5; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 1.1230E+01 / 4.448E-01
AIPS 1:     25.2473011

default tvall; indisk 1; getn 7; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 1.7888E+01 / 6.499E-02
AIPS 1:    275.2423706

default tvall; indisk 1; getn 9; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print  1.8409E+01 / 5.026E-02 
AIPS 1:    366.2753906

default tvall; indisk 1; getn 12; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 4.7158E+01 / 8.304E-02
AIPS 1:    567.8950195









************************ Start Amp SC





*******   
*SPLaT.      Make a zoomed LINE data set to image cube later
*******
default splat
indisk 1; outdisk 1; getn 1

docal 1; gainuse 8
doband 1
flagver 0
aparm(5)=1

sources= 'G23.389''

******* Make a maser target splat file for amp selfcal
bpver 1
outclass 'G23p3';
go; wait; recat; pcat




*** check the cc table of the ICL model
default prtcc; getn 12; go prtcc



Kill and remake the NX table

default indxr; indisk 1; getn 13
cparm 666 666 0.1

go; wait


***************** For Masers

*******
*CALIB
******* 
default calib
indisk 1; getn 13
in2disk 1; get2n 12
NMAPS    1
*Ncomp 25

SOLTYPE  'L1R'
SOLMODE  'A&P'

aparm(7)=7

CALSOUR 'G23.389'
ichansel j,j
SOLINT   60

refant 3

docal -1; gainuse 1
go; wait; imh

*SN1
LOCALH> CALIB1: Found          890 good solutions
LOCALH> CALIB1: Failed on      120 solutions
LOCALH> CALIB1:                 78 solutions had no data





*******
*SNPLT   Look at SN
*******    
default snplt; indisk 1; getn 13; tvinit; dotv 1;
stokes 'half'; do3col 1; opcode 'ALST'
nplots 9
inext 'SN'; invers 1; optype 'AMP'
go; wait



******* 
*CLCAL  Apply Amp SC
*******
default clcal; 
indisk 1; getn 13; refant 3
interpol '';
opcode 'cali'
SOURCES = 'G23.389''
CALSOUR = 'G23.389''

snver 1; gainver 1; gainuse 2
go; wait; imh 



*******
*SNPLT   Look at SN
*******    
default snplt; indisk 1; getn 13; tvinit; dotv 1;
stokes 'half'; do3col 1; opcode 'ALST'
nplots 9
inext 'CL'; invers 2; optype 'AMP'
go; wait





****************** AMP SC Round 1, 60min done










****************** AMP SC Round 2, 60min done



*******
*IMAGR    Image and evaluate the maser using the latest CL table
*******
default imagr
indisk 1; outdisk 1; getn 13
nchav 0; minpatch 128; onebeam -1; maxpixel 0

cellsize 0.001 0.001
imsize 1024 1024

dotv -1; niter 500; robust 0

****** Flag crap data and pick nice UVRANGE
flagver 0
UVWTFN 'NA'
*UVRANGE 000 30000

source 'G23.389'
bchan j; echan j

doband 1
docal 1; gainuse 2
stokes 'I' ; outname 'SCphA1
go; wait; pcat


*CL5 (QSO_FRING phaserefd good stations)
AIPS 1:     4    11 RefM        .IBM001.    1 MA 30-JUL-24 17:57:23
AIPS 1:     5    11 RefM        .ICL001.    1 MA 30-JUL-24 17:59:27

*CL6 (FRINGd maser)
AIPS 1:     6    11 SC_ph1      .IBM001.    1 MA 30-JUL-24 18:05:20
AIPS 1:     7    11 SC_ph1      .ICL001.    1 MA 30-JUL-24 18:05:20

*CL7 (FRINGd maser, Stokes I, solint 0.5, more nComps to include structure)
AIPS 1:     8    11 SC_ph2      .IBM001.    1 MA 30-JUL-24 18:18:32
AIPS 1:     9    11 SC_ph2      .ICL001.    1 MA 30-JUL-24 18:19:04

*CL8 (Same as above but with ACFIT)
AIPS 1:    11    11 SCphA0      .IBM001.    1 MA 31-JUL-24 11:23:00
AIPS 1:    12    11 SCphA0      .ICL001.    1 MA 31-JUL-24 11:23:00


*CL10 (Sae as above but with Selfcal AmpPhas 60min)
AIPS 1:    14    11 SCphA1      .IBM001.    1 MA 31-JUL-24 11:45:37
AIPS 1:    15    11 SCphA1      .ICL001.    1 MA 31-JUL-24 11:45:37




default tvall; indisk 1; getn 5; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 1.1230E+01 / 4.448E-01
AIPS 1:     25.2473011

default tvall; indisk 1; getn 7; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 1.7888E+01 / 6.499E-02
AIPS 1:    275.2423706

default tvall; indisk 1; getn 9; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print  1.8409E+01 / 5.026E-02 
AIPS 1:    366.2753906

default tvall; indisk 1; getn 12; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 4.7158E+01 / 8.304E-02
AIPS 1:    567.8950195

default tvall; indisk 1; getn 15; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 4.8991E+01 / 6.608E-02
AIPS 1:    741.3892822















*************************** Round 2 of AmpPhase Selfcal Done, start round 3



*******
*CALIB
******* 
default calib
indisk 1; getn 13
in2disk 1; get2n 15
NMAPS    1
*Ncomp 25

SOLTYPE  'L1R'
SOLMODE  'A&P'

aparm(7)=7

CALSOUR 'G23.389'
ichansel j,j
SOLINT   10

refant 3

docal 1; gainuse 2
go; wait; imh

*SN2

LOCALH> CALIB1: Found          447 good solutions
LOCALH> CALIB1: Failed on       65 solutions
LOCALH> CALIB1:                 54 solutions had no data




*******
*SNPLT   Look at SN
*******    
default snplt; indisk 1; getn 13; tvinit; dotv 1;
stokes 'half'; do3col 1; opcode 'ALST'
nplots 9
inext 'SN'; invers 2; optype 'AMP'
go; wait



******* 
*CLCAL  Apply Amp SC
*******
default clcal; 
indisk 1; getn 13; refant 3
interpol '';
opcode 'cali'
SOURCES = 'G23.389''
CALSOUR = 'G23.389''

snver 2; gainver 2; gainuse 3
go; wait; imh 



*******
*SNPLT   Look at SN
*******    
default snplt; indisk 1; getn 13; tvinit; dotv 1;
stokes 'half'; do3col 1; opcode 'ALST'
nplots 9
inext 'CL'; invers 3; optype 'AMP'
go; wait





****************** AMP SC Round 3, 10min done










****************** AMP SC Round 2, 60min done



*******
*IMAGR    Image and evaluate the maser using the latest CL table
*******
default imagr
indisk 1; outdisk 1; getn 13
nchav 0; minpatch 128; onebeam -1; maxpixel 0

cellsize 0.001 0.001
imsize 1024 1024

dotv -1; niter 500; robust 0

****** Flag crap data and pick nice UVRANGE
flagver 0
UVWTFN 'NA'
*UVRANGE 000 30000

source 'G23.389'
bchan j; echan j

doband -1
docal 1; gainuse 3
stokes 'I' ; outname 'SCphA2
go; wait; pcat


*CL5 (QSO_FRING phaserefd good stations)
AIPS 1:     4    11 RefM        .IBM001.    1 MA 30-JUL-24 17:57:23
AIPS 1:     5    11 RefM        .ICL001.    1 MA 30-JUL-24 17:59:27

*CL6 (FRINGd maser)
AIPS 1:     6    11 SC_ph1      .IBM001.    1 MA 30-JUL-24 18:05:20
AIPS 1:     7    11 SC_ph1      .ICL001.    1 MA 30-JUL-24 18:05:20

*CL7 (FRINGd maser, Stokes I, solint 0.5, more nComps to include structure)
AIPS 1:     8    11 SC_ph2      .IBM001.    1 MA 30-JUL-24 18:18:32
AIPS 1:     9    11 SC_ph2      .ICL001.    1 MA 30-JUL-24 18:19:04

*CL8 (Same as above but with ACFIT)
AIPS 1:    11    11 SCphA0      .IBM001.    1 MA 31-JUL-24 11:23:00
AIPS 1:    12    11 SCphA0      .ICL001.    1 MA 31-JUL-24 11:23:00


*CL2 (Sae as above but with Selfcal AmpPhas 60min)
AIPS 1:    14    11 SCphA1      .IBM001.    1 MA 31-JUL-24 11:45:37
AIPS 1:    15    11 SCphA1      .ICL001.    1 MA 31-JUL-24 11:45:37

*CL3 (Sae as above but with Selfcal AmpPhas 10min)
AIPS 1:    16    11 SCphA2      .IBM001.    1 MA 31-JUL-24 11:51:23
AIPS 1:    17    11 SCphA2      .ICL001.    1 MA 31-JUL-24 11:51:23



default tvall; indisk 1; getn 5; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 1.1230E+01 / 4.448E-01
AIPS 1:     25.2473011

default tvall; indisk 1; getn 7; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 1.7888E+01 / 6.499E-02
AIPS 1:    275.2423706

default tvall; indisk 1; getn 9; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print  1.8409E+01 / 5.026E-02 
AIPS 1:    366.2753906

default tvall; indisk 1; getn 12; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 4.7158E+01 / 8.304E-02
AIPS 1:    567.8950195

default tvall; indisk 1; getn 15; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 4.8991E+01 / 6.608E-02
AIPS 1:    741.3892822

* Flux = 0
default tvall; indisk 1; getn 17; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

print 5.0088E+01 / 5.148E-02
AIPS 1:    972.9603882





*************************** Round 3 of AmpPhase Selfcal Done, start round 4



*******
*CALIB
******* 
default calib
indisk 1; getn 13
in2disk 1; get2n 17
NMAPS    1
*Ncomp 25

SOLTYPE  'L1R'
SOLMODE  'A&P'

aparm(7)=7

CALSOUR 'G23.389'
ichansel j,j
SOLINT   3

refant 3

docal 1; gainuse 3
go; wait; imh

*SN3






*******
*SNPLT   Look at SN
*******    
default snplt; indisk 1; getn 13; tvinit; dotv 1;
stokes 'half'; do3col 1; opcode 'ALST'
nplots 9
inext 'SN'; invers 3; optype 'AMP'
go; wait



******* 
*CLCAL  Apply Amp SC
*******
default clcal; 
indisk 1; getn 13; refant 3
interpol '';
opcode 'cali'
SOURCES = 'G23.389''
CALSOUR = 'G23.389''

snver 3; gainver 3; gainuse 4
go; wait; imh 



*******
*SNPLT   Look at SN
*******    
default snplt; indisk 1; getn 13; tvinit; dotv 1;
stokes 'half'; do3col 1; opcode 'ALST'
nplots 9
inext 'CL'; invers 4; optype 'AMP'
go; wait





****************** AMP SC Round 3, 10min done










****************** AMP SC Round 2, 60min done



*******
*IMAGR    Image and evaluate the maser using the latest CL table
*******
default imagr
indisk 1; outdisk 1; getn 13
nchav 0; minpatch 128; onebeam -1; maxpixel 0

cellsize 0.001 0.001
imsize 1024 1024

dotv -1; niter 500; robust 0

****** Flag crap data and pick nice UVRANGE
flagver 0
UVWTFN 'NA'
*UVRANGE 000 30000

source 'G23.389'
bchan j; echan j

doband -1
docal 1; gainuse 4
stokes 'I' ; outname 'SCphA3
go; wait; pcat


*CL5 (QSO_FRING phaserefd good stations)
AIPS 1:     4    11 RefM        .IBM001.    1 MA 30-JUL-24 17:57:23
AIPS 1:     5    11 RefM        .ICL001.    1 MA 30-JUL-24 17:59:27

*CL6 (FRINGd maser)
AIPS 1:     6    11 SC_ph1      .IBM001.    1 MA 30-JUL-24 18:05:20
AIPS 1:     7    11 SC_ph1      .ICL001.    1 MA 30-JUL-24 18:05:20

*CL7 (FRINGd maser, Stokes I, solint 0.5, more nComps to include structure)
AIPS 1:     8    11 SC_ph2      .IBM001.    1 MA 30-JUL-24 18:18:32
AIPS 1:     9    11 SC_ph2      .ICL001.    1 MA 30-JUL-24 18:19:04

*CL8 (Same as above but with ACFIT)
AIPS 1:    11    11 SCphA0      .IBM001.    1 MA 31-JUL-24 11:23:00
AIPS 1:    12    11 SCphA0      .ICL001.    1 MA 31-JUL-24 11:23:00


*CL2 (Sae as above but with Selfcal AmpPhas 60min)
AIPS 1:    14    11 SCphA1      .IBM001.    1 MA 31-JUL-24 11:45:37
AIPS 1:    15    11 SCphA1      .ICL001.    1 MA 31-JUL-24 11:45:37

*CL3 (Sae as above but with Selfcal AmpPhas 10min)
AIPS 1:    16    11 SCphA2      .IBM001.    1 MA 31-JUL-24 11:51:23
AIPS 1:    17    11 SCphA2      .ICL001.    1 MA 31-JUL-24 11:51:23

*CL3 (Sae as above but with Selfcal AmpPhas 3min)
AIPS 1:    18    11 SCphA3      .IBM001.    1 MA 31-JUL-24 12:00:24
AIPS 1:    19    11 SCphA3      .ICL001.    1 MA 31-JUL-24 12:00:24





default tvall; indisk 1; getn 5; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 1.1230E+01 / 4.448E-01
AIPS 1:     25.2473011

default tvall; indisk 1; getn 7; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 1.7888E+01 / 6.499E-02
AIPS 1:    275.2423706

default tvall; indisk 1; getn 9; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print  1.8409E+01 / 5.026E-02 
AIPS 1:    366.2753906

default tvall; indisk 1; getn 12; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 4.7158E+01 / 8.304E-02
AIPS 1:    567.8950195

default tvall; indisk 1; getn 15; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

>print 4.8991E+01 / 6.608E-02
AIPS 1:    741.3892822

default tvall; indisk 1; getn 17; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

print 5.0088E+01 / 5.148E-02
AIPS 1:    972.9603882

default tvall; indisk 1; getn 19; txinc 1; tyinc 1
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat

print 5.0637E+01 / 3.601E-02
AIPS 1:   1406.192749





**************************************.     END AMP SC






















*************** Exporting AIPS products


****** If youre happy with the final MOMNTS and SpotMap then 
****** FITOUT calibrated UVdata for backup.
****** We can always re-image again from this log, to do so
****** go back to Popcorn


*******   First, apply the full calibration and split
*SPLaT   (use same settings that were used in IMAGR above)
*******
default splat; indisk 1; outdisk 1; getn 13
docal 1; gainuse 4; doband -1
sources= 'G23.389''
outclass 'FITTP'
outname 'DONE'
bchan j-150; echan J+150
go; wait; recat; pcat

AIPS 1:    20    11 DONE        .FITTP .    1 UV 31-JUL-24 12:02:46



*******   Then, FITTP it out and copy it to an external device
*FITTP
*******
default fittp; indisk 1; getn 20
dataout 'PWD:RB010_G23.389calbrtd.fits
go; wait

**** 3 Gb



*******   FIT out MOMNTS
*FITTP
*******
default fittp; indisk 1; getn 31
dataout 'PWD:BB444A_G23.389_MOM0.fits
go; wait

default fittp; indisk 1; getn 32
dataout 'PWD:BB444A_G23.389_MOM1.fits
go; wait









*******
*IMAGR     Map time
*******
default imagr
indisk 1; outdisk 1; getn 13
nchav 0; minpatch 128; onebeam -1; maxpixel 0

cellsize 0.001 0.001
imsize 1024 1024

dotv -1; niter 500; robust 0

****** Flag crap data and pick nice UVRANGE
flagver 0

*UVRANGE 000 30000

source 'G23.389'
bchan j-70; echan j+70

doband -1
docal 1; gainuse 4
stokes 'I' ; 

UVWTFN 'NA'
outname 'C4NA

go; wait; pcat

UVWTFN ''
outname 'C4UN

go; wait; pcat


***** Natural weighting


***** Uniform weighting


here 31 July 2024



********** TVMOVIE
default tvmovie; tvinit; indisk 1; txinc 2; tyinc 2; getn 22
tvmovie



********** TVLOD
default tvlod; tvinit; indisk 1; getn 22
txinc 2; tyinc 2; ltype 4; tvlod; tvlab
pixrange -0.1 5
detime 0.2
for i = 22 to 140; tblc 0 0 i;ttrc 0 0 i;tvlod; delay; end


* Check the SNR of the ref maschan is near 800
default tvall; indisk 1; getn 22; txinc 3; tyinc 3
for i =71 to 71; tblc 0 0 i;ttrc 0 0 i;
tvall; tvlab; docirc 1; ltype 4; tvlab
tvwin; imstat; tvwin; imstat


** Natural Conv size= 0.01337 X 0.00452
>print 5.0638E+01 / 3.557E-02
AIPS 1:   1423.6154785

** Uniform Conv size= 0.00930 X 0.00494







*******  Prepare ICL file for making moment maps
*TRANSPOSE
*******
default trans
indisk 1; outdisk 1; 

transcod '312'

getn 22
altswtch
go; wait; recat; pcat

AIPS 1:    23    11 C4NA        .TRANS .    1 MA 31-JUL-24 13:01:25



* for i = 28 to 39; getn i; zap; end

*******
*MOMNT   
******* 
default momnt; indisk 1; outdisk 1; icut = 0

getn 23
flux 0.9
go; wait; recat; pcat





******* Adds a ST file to your image getn, for plotting. First:
*STARS    make a starfile called STAR.dat, containing one line 
*******  with the coords as HH MM SS.s DD AM AS.s
default stars; indisk 1; getn 18
INTEXT     'PWD:STAR.dat
stvers 1; X 3; go; wait

Bartk
We found 18 maser spots associated with source G23.389+0.185 observed by Bartkiewicz et al. (2009) using EAVN;
The reference position is RAJ2000 = +18 33 14.3248, DecJ2000 = -08 23 57.4723;

ellipse center is at −34, −75 mas from 
18 33 14.32477 −08 23 57.4723
therefore 
18 33 14.32477 −08 23 57.4723


*******
*KNTR   Colours robust 1
*******
default kntr ; tvinit
indisk 1; dogrey -1; dovect -1; ltype -3


clev 1.924E2
levs 0,1,2,4,8,16,32,64,128,256,512,1024,2048,4196
levs 1,3,9,27,81,243

*plev 100
*levs 0.1, 0.2, 0.3


indisk 1;
getn 24
in2disk 1;
get2n 25

**** color
dogrey 2
ofmfile 'rainbow'

 stvers 1
 stfactor -10

pixrange 0
   getn 24; tvall; tvwin
*pixrange 1000, 19000

tvinit
dotv = 1
*go; wait




clev 1.034E01
levs 0,1,2,4,8,16,32,64,128,256,512,1024,2048
*levs 0.01, 1,3,9,27,81,243
*pixrange 1000, 19000
darkline 0.1
*dotv = -1
go; wait





*******
*LWPLA
*******
default lwpla 
indisk 1; getn 24
plver 1
outfile 'PWD:RB010_MOM_2.eps
go;wait 






*************** Exporting AIPS products


****** If youre happy with the final MOMNTS and SpotMap then 
****** FITOUT calibrated UVdata for backup.
****** We can always re-image again from this log, to do so
****** go back to Popcorn


AIPS 1:    24    11 C4NA        .MOM0  .    1 MA 31-JUL-24 13:05:28
AIPS 1:    25    11 C4NA        .MOM1  .    1 MA 31-JUL-24 13:04:15
AIPS 1:    26    11 C4NA        .MOM2  .    1 MA 31-JUL-24 13:01:46

*******   FIT out MOMNTS
*FITTP
*******
default fittp; indisk 1; getn 24
dataout 'PWD:RB010_G23p389_MOM0.fits
go; wait

default fittp; indisk 1; getn 25
dataout 'PWD:RB010_G23p389_MOM1.fits
go; wait









